package com.jiepos.mpos.biz.insaccountstatement.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.insaccountstatement.service.InsAccountStatementService;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 * 
 * 机构对账报表查看及下载
 * 
 * @ProjectName: [mpos1]
 * @Package com.jiepos.mpos.biz.customer.controller
 * @author 肖志伟
 * @version 1.0
 * @since 2017年9月25日 上午11:32:40
 * @history（历次修订内容、修订人、修订时间等） @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("insaccountstatement")
public class InsAccountStatementController extends BaseController {

	@Autowired
	private InsAccountStatementService insAccountStatementService;

	/**
	 * 进入会员信息列表页界面
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getInsAccountStatementList.do")
	public ModelAndView getCustomerAccountList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView model = new ModelAndView("/module/insaccountstatement/insreportform/insreportform_list");
		return super.getDetail(request, response, model);
	}

	/**
	 * 查询会员账户json数据
	 * 
	 * @param pagination
	 *            分页实体
	 * @param appCustomAccountEntity
	 *            会员账户对象
	 * @param ins_cd
	 *            机构编码
	 * @return
	 */
	@RequestMapping("/getInsAccountStatementListJson.do")
	public @ResponseBody Map getCustomerInfoListJson(HttpServletRequest request, Pagination pagination,String start_date, String end_date) {
		return insAccountStatementService.getFileList(request, pagination, start_date, end_date);
	}
	
	/**
	 * 下载文件
	 * @param request
	 * @param response
	 * @param fileName
	 * @param date
	 */
	@RequestMapping("/exportFile.do")
	@ResponseBody
	public void exportTransactionLogs(HttpServletRequest request, HttpServletResponse response,
			String fileName) {
		super.clearCookie(request, response);
		insAccountStatementService.downloadFile(fileName, response, request);
	}
	
	@RequestMapping("/resetReport.do")
	@ResponseBody
	public boolean resetReport(HttpServletRequest request, HttpServletResponse response, String beginDate, String endDate){
		try{
			insAccountStatementService.resetReport(request,beginDate,endDate);
			return true;
		}catch(Exception e){
			e.printStackTrace();
		}
		return false;
	}
}
